<template>
  <div class="app-container">
    <wms-form v-model="queryParams" :form-list="formList" @query="getList" label-width="108px" @export="handleExport">
    </wms-form>
    <wms-table :loading="loading" :data-list="customerList" :column="column" :pageInfo="queryParams" @get-list="getList"/>
  </div>
</template>

<script setup name="Customer">
import WmsTable from '@/components/WmsTable/index.vue'
import WmsForm from '@/components/WmsForm/index.vue'
import { listCustomer } from "@/api/wms/customer";
// 固定字段初始化
import { data, column, formList } from './index.js'
const dataReactive = reactive(data);
const { queryParams, form, rules } = toRefs(dataReactive);
// end

const { proxy } = getCurrentInstance();
const { wms_common_status } = proxy.useDict("wms_common_status");
const customerList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
/** 查询客户资料列表 */
function getList() {
  loading.value = true;
  listCustomer(queryParams.value).then((response) => {
    customerList.value = response.rows;
    queryParams.value.total = response.total;
    loading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "wms/customer/export",
    {
      ...queryParams.value,
    },
    `customer_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
